Skip to content

Conversation

leodido
Copy link

@leodido leodido commented Oct 2, 2025

Add Integration Tests for Docker Export to Cache

Description

This PR adds comprehensive integration tests for the Docker image export to cache functionality introduced in the previous PR. These tests verify the complete end-to-end behavior of the feature across different configuration methods and scenarios.

What's Tested:

  1. Default Behavior: Verifies that Docker images are NOT exported to cache by default (backward compatibility)
  2. Package Config: Tests enabling export via exportToCache: true in BUILD.yaml
  3. CLI Flag Override: Tests --docker-export-to-cache flag overriding package config in both directions
  4. Environment Variable: Tests LEEWAY_DOCKER_EXPORT_TO_CACHE environment variable
  5. Metadata Extraction: Verifies correct metadata extraction from exported Docker images
  6. Cache Structure: Validates the cache artifact structure and content

Test Coverage:

  • All configuration precedence levels (env var > CLI flag > package config > default)
  • Cache artifact creation and structure
  • Metadata file generation and content
  • Image digest extraction
  • Backward compatibility (no export by default)

Related Issue(s)

Fixes https://linear.app/ona-team/issue/CLC-1958/leeway-security-testing-suite
Fixes https://linear.app/ona-team/issue/CLC-2009/docker-export-mode-for-slsa-l3-compliance-leeway

Depends on: #248

How to test

Run the integration tests:

# Run all integration tests
go test -v ./pkg/leeway -run TestDockerExportToCache

# Run specific test scenario
go test -v ./pkg/leeway -run TestDockerExportToCache/default_no_export
go test -v ./pkg/leeway -run TestDockerExportToCache/export_via_config
go test -v ./pkg/leeway -run TestDockerExportToCache/cli_flag_override

Expected Results:

  • All tests should pass
  • Tests verify cache artifacts are created only when export is enabled
  • Metadata files contain correct image digests and references

Documentation

  • Yes
  • No

No additional documentation needed - these are integration tests that complement the existing unit tests and documentation from the previous PR.

Checklist

  • Integration tests added
  • Tests cover all configuration methods
  • Tests verify cache artifact structure
  • Tests verify metadata extraction
  • Backward compatibility verified
  • All tests pass locally

- Add comprehensive integration tests for exportToCache functionality
- Test default behavior (no export)
- Test export via package config
- Test CLI flag override (both directions)
- Test environment variable
- Test metadata extraction from exported images
- Verify cache artifact structure and content

Co-authored-by: Ona <[email protected]>
@leodido leodido self-assigned this Oct 2, 2025
@leodido leodido requested review from aledbf, csweichel and geropl October 2, 2025 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants